﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BrnMall.Manager.Manager.Cart
{
    public static class CartManager
    {
        public static void UpdateProductIsPrint(IList<int> recordids)
        {
            using (var db = new QDMallDatabase())
            {
                db.Execute($"update bma_orderproducts set isprint=1 where oid=0 and  recordid in({string.Join(",",recordids)})");
            }
        }

        public static void UpdateRecoredPrinted(int recordId)
        {
            using (var db = new QDMallDatabase())
            {
                db.Execute($"update bma_orderproducts set printed=1 where oid=0 and recordid={recordId}");
            }
        }

        public static bool CheckPrinted(int recordId)
        {
            using (var db = new QDMallDatabase())
            {
                return db.ExecuteScalar<bool>(
                    $"select printed from bma_orderproducts  where oid=0 and recordid={recordId}");
            }
        }

        public static int GetIsPrintCountBySid(string sid)
        {
            if (string.IsNullOrEmpty(sid)) return 0;
            using (var db = new QDMallDatabase())
            {
                return db.ExecuteScalar<int>(
                    $"select count(*) from bma_orderproducts where sid='{sid}' and oid=0 and isprint=1");
            }
        }
        public static bool CheckIsPrint(int recordid)
        {
          
            using (var db = new QDMallDatabase())
            {
                return db.ExecuteScalar<bool>(
                    $"select isprint from bma_orderproducts where recordid={recordid}");
            }
        }
    }
}
